<template>
  <div class="camera-info-overlay" v-show="show">
    <div class="close-btn" @click="close">
      <i class="el-icon-close"></i>
    </div>
    <div class="bottom__arrow"></div>
    <template v-if="details">
      <div class="camera-info-warp">
        <div class="camera-info-item">
          <div class="text-label text-justify maohao">报警时间</div>
          <div class="omit">{{details.alarmDate}}</div>
        </div>
        <div class="camera-info-item">
          <div class="text-label text-justify maohao">相机名称</div>
          <div class="omit" :title="details.cameraName">{{details.cameraName}}</div>
        </div>
        <div class="camera-info-item">
          <div class="text-label text-justify maohao">区域</div>
          <div class="omit">{{details.policeStationName}}</div>
        </div>
      </div>
    </template>
  </div>
</template>
<script>

export default {
  title: '点位消息弹窗',
  props: {
    btns: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {
      show: false,
      self: null,
      feature: null,
      coordinate: undefined,
      overlayId: null,
      details: null,
    }
  },
  methods: {
    /**
     * 传入数据
     */
    onData({self = null, feature = null, coordinate = undefined, data = {}, overlayId = null}) {
      this.show = true
      this.self = self
      this.feature = feature
      this.coordinate = coordinate
      this.overlayId = overlayId
      this.details = Object.assign({}, data)
    },
    /**
     * 查看详情（点击图片）
     */
    onLookDetails() {
      this.$emit('lookDetails', this.details)
    },
    /**
     * 关闭
     */
    close() {
      if (!this.self) {
        this.show = false
        return console.log('this.self')
      }
      if (this.overlayId) {
        this.self.gisIns.removeOverLayById(this.overlayId)
      }
      this.self.toMapZoomCenter(this.coordinate)
    },
  },
}
</script>
<style scoped lang="scss">
  .camera-info-overlay {
    background: #FFFFFF;
    padding: 15px;
    width: 240px;
    box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.5);
    border-radius: 3px;
    position: relative;

    .close-btn {
      position: absolute;
      top: 5px;
      right: 5px;
      width: 20px;
      height: 20px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;

      i {
        font-size: 14px;
      }

      &:hover {
        color: red;
        background-color: #ececec;
      }
    }

    .bottom__arrow {
      border-width: 6px;
      filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
      position: absolute;
      bottom: 1px;
      left: calc(50%);
      margin-right: 3px;
      border-bottom-width: 0;
      border-bottom-color: #EBEEF5;
      &::after {
        content: " ";
        border-width: 6px;
        position: absolute;
        display: block;
        width: 0;
        height: 0;
        border-color: transparent;
        border-style: solid;
        top: 1px;
        margin-left: -6px;
        border-bottom-width: 0;
        border-top-color: #fff;
      }
    }


    .camera-info-item {
      display: flex;
      align-items: center;
      overflow: hidden;
      margin-top: 10px;
      font-size: 12px;

      .text-label {
        width: 60px;
        flex-shrink: 0;
      }
    }
  }
</style>
